/*
 * @Author       : huangzb
 * @Date         : 2024-01-18 09:48:59
 * @LastEditors: guangyunl
 * @LastEditTime: 2024-03-21 00:53:21
 * @Description  : file content
 * @FilePath     : \PcBackend\src\views\Classes\config.js
 */
let validatePass = (rule, value, callback) => {
  let regular = /^\+?[0-9]\d*$/;
  if (value && !regular.test(value)) {
    callback(new Error('排序字段需为正整数'));
  } else {
    callback();
  }
}

const Main_Option = (cidDicData=[])=>{
  return {
    headerAlign: "center",
    align: "center",
    border: true,
    index: true,
    menuWidth: 150,
    // editBtn: false,
    // delBtn: false,
    editBtnIcon: ' ',
    delBtnIcon: ' ',
    // dialogMenuPosition: 'center',
    // defaultExpandAll:true,
    column: [
      {
        label: "类别名称",
        prop: "title",
        search: true,
        rules: [{
          required: true,
          message: "请输入名称",
          trigger: "blur"
        }],
      },
      {
        label: "一级分类",
        prop: "cid",
        type: "select",
        props: {
          label: "title",
          value: "id",
        },
        dicData: cidDicData || [],
      },
      {
        label: "分类图片",
        prop: "img",
        align: "center",
        slot: true, // 是否开启表格插槽
        
      },
      {
        label: "排序",
        prop: "sort",
        rules: [{
          validator: validatePass,
          trigger: "blur"
        }],
      },
      {
        label: "新建时间",
        prop: "createdAt",
        display: false,
      },
      {
        label: "最后更新时间",
        prop: "updatedAt",
        display: false,
      },
    ]
  }
}

const Main_Data = []

export {
  Main_Option,
  Main_Data,
}
